﻿using CMSDemo.Models;
using Microsoft.AspNetCore.Mvc;
using Microsoft.Extensions.Options;
using System;
using System.Collections.Generic;

namespace CMSDemo.Controllers
{
    public class ContentController : Controller
    {
        public readonly Content contents;
        public ContentController(IOptions<Content> _contents)
        {
            contents = _contents.Value;
        }
        public IActionResult Index()
        {
            var contentList = new List<Content>();
            for (int i = 1; i < 11; i++)
            {
                contentList.Add(new Content { Id = i, title = $"{i}的标题", content = $"{i}的内容", status = 1, add_time = DateTime.Now.AddDays(-i) });
            }

            return View(new ContentViewModel { Contents = new List<Content> { contents } });
        }
    }
}